<script setup>
import { onLaunch } from '@dcloudio/uni-app'
import { useAppInfoStore } from '@/stores/appInfo'

const appInfoStore = useAppInfoStore()
//获取设备信息
const saveDeviceInfo = (e) => {
  let statusBar = 0 //状态栏高度
  // #ifdef MP
  statusBar = e.statusBarHeight
  if (e.platform === 'android') {
  }
  // #endif
  // #ifdef MP-WEIXIN
  statusBar = e.statusBarHeight
  // #endif

  // #ifdef MP-ALIPAY
  statusBar = e.statusBarHeight
  // #endif

  // #ifdef APP-PLUS
  statusBar = e.statusBarHeight
  // #endif

  // #ifdef H5
  statusBar = 0
  // #endif

  const navBarHeight = 45
  const deviceId = e.deviceId
  const deviceBrand = e.deviceBrand
  appInfoStore.setInfo(
    statusBar,
    navBarHeight,
    e.screenWidth,
    e.screenHeight,
    deviceId,
    deviceBrand,
    e.appWgtVersion
  )
}

onLaunch(() => {
  uni.getSystemInfo({
    success: (e) => {
      saveDeviceInfo(e)
    },
  })
})
</script>